import yaml
from SQ_UI.common.doPath import *
import os



def get_ele_locator(filePath, ele_name):
    """
        根据路径获取yml文件的元素定位和定位属性值
    :param filePath: 元素定位yml文件地址
    :param ele_name: 元素在yml文件中的所要找的定位属性的K值
    :return: 属性定位方式,属性值
    """
    with open(filePath, 'r', encoding='utf-8') as file:
        data = yaml.safe_load(file)
    element_info = data[ele_name]
    ele_list = element_info.split("=", 1)
    locator_type = ele_list[0]
    locator_value = ele_list[1]
    return [f"{locator_type}",f"{locator_value}"]

def get_current_package_name(current_file):
    return os.path.basename(current_file).split(".")[0] + ".yml"



if __name__ == '__main__':
    # pass
    # print(get_ele_locator("../config/elementLocators/login_page.yml", "username_input"))
    #
    print(get_current_package_name(os.path.abspath(__file__)))

